package com.hp.service;



import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hp.bean.Customerservice;
import com.hp.bean.CustomerserviceExample;
import com.hp.mapper.CustomerserviceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerserviceServiceImpl implements CustomerserviceService {
    @Autowired
    private CustomerserviceMapper mapper;

    @Override
    public Customerservice login(CustomerserviceExample obj) {
        List<Customerservice> list = mapper.selectByExample(obj);
        if (list != null && list.size() > 0) {
            return list.get(0);
        } else {
            return null;
        }
    }

    @Override
    public List<Customerservice> find(CustomerserviceExample obj, Integer page, Integer limt) {
        return mapper.selectByExample(obj);
    }

    @Override
    public Customerservice findByid(Integer id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public int add(Customerservice obj) {
        return mapper.insertSelective(obj);
    }

    @Override
    public int upp(Customerservice obj) {
        return mapper.updateByPrimaryKeySelective(obj);
    }

    @Override
    public int del(Integer id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public PageInfo<Customerservice> pageFind(CustomerserviceExample example, Integer page, Integer limit) {
        PageHelper.startPage(page, limit);
        List<Customerservice> list = mapper.selectByExample(example);
        PageInfo<Customerservice> pageInfo = new PageInfo<Customerservice>(list);
        return pageInfo;

    }
}